home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 1314 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: mail2news.demon.co.uk!genesis.demon.co.uk
  2. From: Lawrence Kirby <fred@genesis.demon.co.uk>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Comma Delimited function wanted
  5. Date: Sat, 13 Jan 96 00:21:21 GMT
  6. Organization: none
  7. Message-ID: <821492481snz@genesis.demon.co.uk>
  8. References: <4d1l42$mb6@voyager.Internex.NET> <4d4gic$p7u@umbc9.umbc.edu> <4d6gi2$g4r@news.iag.net>
  9. Reply-To: fred@genesis.demon.co.uk
  10. X-NNTP-Posting-Host: genesis.demon.co.uk
  11. X-Newsreader: Demon Internet Simple News v1.27
  12. X-Mail2News-Path: genesis.demon.co.uk
  13.  
  14. In article <4d6gi2$g4r@news.iag.net> jatmon@iag.net "John R Buchan" writes:
  15.  
  16. >  char *buffer = "3740067099,,P03,5000";  
  17. >
  18. >A strtok based solution will have a similar problem.  A full solution to 
  19. >this type of parsing will require a non-standard function (custom code).
  20.  
  21. I don't recommend passing pointers to string literals as strtok's first
  22. argument. If a token exists strtok will attempt to modify the string
  23. by null character terminating the token. With string literals this
  24. results in undefined behaviour. better would be:
  25.  
  26.   static char buffer[] = "3740067099,,P03,5000";  
  27.  
  28. -- 
  29. -----------------------------------------
  30. Lawrence Kirby | fred@genesis.demon.co.uk
  31. Wilts, England | 70734.126@compuserve.com
  32. -----------------------------------------
  33.